document.getElementById("inputForm").addEventListener("submit", function (e) {
  e.preventDefault();

  const formData = new FormData(this);
  const text = formData.get("text") || "";

  document.body.innerHTML =
    '<div class="text-center text-lg mt-10">数据处理中...</div>';

  fetch("/", { method: "POST", body: formData })
    .then((response) => response.json())
    .then((data) => {
      localStorage.setItem("analysisResult", JSON.stringify(data));
      localStorage.setItem("inputText", text);
      window.location.href = "/result";
    });
});
